package day1105.second;

import day1105.common.MyUtil;
import day1105.common.Student;

import java.util.List;

import static day1105.common.MyUtil.printLine;

/**
 * @author Mr.ma
 * @since 2022/11/6 15:38
 * 测试max、min、count
 **/
public class CountTest {
    public static void main(String[] args) {
        List<Student> studentList = MyUtil.createStudentList();
        studentList.stream().forEach(System.out::println);
        printLine("年龄最大的学生");
        Student student = studentList.stream().max(Student::compareTo).get();
        System.out.println("student = " + student);
        printLine("分数最低的学生");
        Student student1 = studentList.stream().min((x1, x2) -> x1.getScore().compareTo(x2.getScore())).get();
        System.out.println("student1 = " + student1);
        printLine("统计各班人数");
        long count = studentList.stream().filter(s -> "一班".equals(s.getClazz())).count();
        System.out.println("一班总人数为： " + count);
        long count1 = studentList.stream().filter(s -> "二班".equals(s.getClazz())).count();
        System.out.println("二班总人数为： " + count1);
    }
}
